<?php
//使用操作符：计算表单的总金额
//计算Bob订单表单的总金额和税金
$tireqty = 100;
$oilqty = 200;
$sparkqty = 300;
$totalqty = 0;
//通过添加操作符计算订单的总金额
$totalqty = $tireqty + $oilqty + $sparkqty;
echo 'Item ordered ' . $totalqty.'<br/>';

$totalamout = 0.00;
//新价格
define('TIREPRICE',100);
//旧价格
define('OILPRICE',10);
define('SPARKPRICE',4);
//计算总价格
$totalamout = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE;
//number_format   格式化   给当前的数目保存两位小数
echo 'Subtotal:$' . number_format($totalamout,2).'<br/>';

//计算现在总价格需要交的税金
$taxrate = 0.10;
$totalamout1 = $totalamout * (1 + $taxrate);
echo  'Total including tax: $' . number_format($totalamout1,2).'<br/>';

echo '需要缴税' . number_format($totalamout1 - $totalamout);

